<?php

class MomentsAction extends Action {
	public function getMoments() {
		if(IS_AJAX) {
			$token = session('school_token');
			$page = I('page', 1, 'intval');
			$rowNum = I('rowNum', 10, 'intval');
			$startPage = ($page - 1) * $rowNum;
			$total = M('school_alumni_allclass')->where(array('token' => $token, 'is_pass' => 0))->count('id');
			$moments = M('school_alumni_allclass')->alias('a')
								->join('tp_school_alumni_user as b on a.userid=b.id')
								->field(array('a.id, a.content, a.imgsrc, a.classroom, a.pubdate, a.is_pass, b.truename'))
								->where(array('a.token' => $token, 'a.is_pass' => 0))
								->order('a.pubdate')->limit($startPage.','.$rowNum)->select();
			$this->ajaxReturn( array('status' => 200, 'total' => $total, 'data' => $moments), 'json');
		}
	}

	public function verifyPass() {
		if (IS_AJAX) {
			$ids = I('ids');
			foreach($ids as $id) {
				M('school_alumni_allclass')->where(array('id' => $id))->save(array('is_pass' => 1));
			}
			$this->ajaxReturn(array('status'=> 200, 'msg' => 'success'), 'json');
		}
	}
}
?>